package com.macro.mall.portal.service.impl;

import com.github.pagehelper.PageHelper;
import com.macro.mall.mapper.BmsRecruitmentInformationMapper;
import com.macro.mall.mapper.BmsRecuitmentInformationPicMapper;
import com.macro.mall.model.BmsRecruitmentInformation;
import com.macro.mall.model.UmsMember;
import com.macro.mall.portal.dto.BmsGuidePointDetail;
import com.macro.mall.portal.dto.BmsRecruitmentInformationDetail;
import com.macro.mall.portal.dto.BmsRecruitmentInformationParam;
import com.macro.mall.portal.service.BmsRecruitmentInformationService;
import com.macro.mall.portal.util.MemberUtil;
import com.macro.mall.portal.util.MemberUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;


/**
 * 观光车点位图片Service实现类
 * Created by macro on 2018/4/26.
 */
@Service
public class BmsRecruitmentInformationServiceImpl implements BmsRecruitmentInformationService {

    @Autowired
    private BmsRecruitmentInformationMapper bmsRecruitmentInformationMapper;

    @Autowired
    private MemberUtil memberUtil;

    @Autowired
    private BmsRecuitmentInformationPicMapper bmsRecuitmentInformationPicMapper;

    /**
     * 获取列表
     * @param bmsRecruitmentInformationParam
     * @return
     */
    @Override
    public List<BmsRecruitmentInformation> getList(BmsRecruitmentInformationParam bmsRecruitmentInformationParam) {
        BmsRecruitmentInformation bmsRecruitmentInformation = new BmsRecruitmentInformation();
        BeanUtils.copyProperties(bmsRecruitmentInformationParam, bmsRecruitmentInformation);
        List<BmsRecruitmentInformation> list = bmsRecruitmentInformationMapper.getListXiaoChengxu(bmsRecruitmentInformation);
        return list;
    }

    @Override
    public BmsRecruitmentInformation getDetail(BmsRecruitmentInformationParam bmsRecruitmentInformationParam, HttpServletRequest request) {
        UmsMember member = MemberUtils.getUser();
        BmsRecruitmentInformation bri = new BmsRecruitmentInformation();
        BeanUtils.copyProperties(bmsRecruitmentInformationParam, bri);
        bri.setUserId(member.getId());
        BmsRecruitmentInformation bmsRecruitmentInformation = bmsRecruitmentInformationMapper.selectDetail(bri);
        if (bmsRecruitmentInformation != null){
            // 获取封面图
            String coverPic = bmsRecuitmentInformationPicMapper.findCoverPicByActivitiesId(bmsRecruitmentInformationParam.getId());
            // 获取活动图片
            List<String> picList = bmsRecuitmentInformationPicMapper.findPicListByActivitiesId(bmsRecruitmentInformationParam.getId());
            bmsRecruitmentInformation.setCoverPic(coverPic);
            bmsRecruitmentInformation.setPicList(picList);
        }
        return bmsRecruitmentInformation;
    }



}
